<?php
$url='https://h5.cyol.com/special/weixin/sign.json';//网页地址
$yuanma=file_get_contents($url);
$b = substr($yuanma,-21,-11);//最新一期ID
$riqi =date("m/d");//日期
$s = date('w');//周几
$suzu=file('dxx.txt');
$qishu = intval($suzu[0]);
$riqi1 = $suzu[1];
$new = $suzu[2];
$old = $suzu[3];
$content=[$qishu,$riqi1,$new,$old];
if($b.PHP_EOL != $new){
    $old=$new;
    $new=$b.PHP_EOL;
}
if($s == 1 and $riqi.PHP_EOL <> $riqi1){
    $qishu1=$qishu+1;
    $qishu=$qishu1;
    $riqi1 =$riqi.PHP_EOL;
}
$content=[$qishu.PHP_EOL,$riqi1,$new,$old];
file_put_contents('dxx.txt',$content);
foreach ($_GET as $v=>$k){};
if($v=='new'){
    $b = substr($new,0,10);
    $content1=file_get_contents("http://h5.cyol.com/special/daxuexi/".$b."/index.html");
    $pos = strpos($content1,'utf-8');
    if($pos===false){$content1 = iconv("gbk","utf-8",$content1);}
    $postb=strpos($content1,'<title>')+7;
    $poste=strpos($content1,'</title>');
    $length=$poste-$postb;
    $title= substr($content1,$postb,$length);
    echo '<html>
<head>
<meta charset="utf-8">
<title>'.$title.'</title>
</head>
<body>
<div>
<img src="http://h5.cyol.com/special/daxuexi/'.$b.'/images/end.jpg" style="position: absolute;width: 100%;height: 100%;top:0;left: 0 ;">
</div>
</body>
</html>';
    exit();
}
if($v=='old'){
    $b = substr($new,0,10);
    $content1=file_get_contents("http://h5.cyol.com/special/daxuexi/".$b."/index.html");
    $pos = strpos($content1,'utf-8');
    if($pos===false){$content1 = iconv("gbk","utf-8",$content1);}
    $postb=strpos($content1,'<title>')+7;
    $poste=strpos($content1,'</title>');
    $length=$poste-$postb;
    $title= substr($content1,$postb,$length);
    echo '<html>
<head>
<meta charset="utf-8">
<title>'.$title.'</title>
</head>
<body>
<div>
<img src="http://h5.cyol.com/special/daxuexi/'.$b.'/images/end.jpg" style="position: absolute;width: 100%;height: 100%;top:0;left: 0 ;">
</div>
</body>
</html>';
    exit();
}
echo'<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>青年大学习</title>
</head>
<body style="display: flex;flex-direction: column;justify-content: center;align-content: center;height:100vh;">
<div id="particles" style="width: 100%;height: 100vh;overflow: hidden;position: fixed;z-index: -1;top: 0;left: 0;background-color:#4B4B4B"></div>
<p style="margin: 0 auto 0 auto;font-size: 150px;height: 200px;opacity: 0.5;color:white;">学习新思想</p>
<p style="margin: 0 auto 200px auto;font-size: 150px;height: 200px;opacity: 0.5;color:white;">争做新青年</p>
<button style="margin: 0 auto 50px auto;font-size: 55px;width: 800px;height: 200px;opacity: 0.5;border-radius: 100px;">本周最新应为2022年'.$qishu.'期<br>'.$riqi1.'更新</button>
<a style="margin: 0 auto;" href="new.php"><button style="margin: 0 auto;font-size: 100px;width: 800px;height: 200px;opacity: 0.5;border-radius: 100px;">最新一期</button></a>
<a style="margin: 0 auto;" href="old.php"><button style="margin: 50px auto 0 auto;font-size: 100px;width: 800px;height: 200px;opacity: 0.5;border-radius: 100px;">上一期</button></a>
<button style="margin: 50px auto 0 auto;font-size: 60px;width: 800px;opacity: 0.5;border-radius: 100px;"onclick="myFunction()"id="myPar">公众号(关注获取最新更新)</button>
<script src="gzh.js"></script>
</body>
</html>';
